package biz.ezcom.design.pattern.prototype;

import java.util.Date;

public class Client {

    public static void main(String[] args) {
    	System.out.println("========浅克隆===============");
        PrototypeDeep prototypeDeep = new PrototypeDeep();
        prototypeDeep.setName("felix");
        prototypeDeep.setDate(new Date());
        PrototypeDeep cloneDeep = (PrototypeDeep) prototypeDeep.clone();
        
        System.out.println("对象 : " + (prototypeDeep == cloneDeep));
        System.out.println("对象.ֵname: " + (prototypeDeep.getName() == cloneDeep.getName()));
        System.out.println("对象.Date: " + (prototypeDeep.getDate() == cloneDeep.getDate()));
        System.out.println("对象.Date.ֵtime: " + (prototypeDeep.getDate().getTime() == cloneDeep.getDate().getTime()));
        
        System.out.println("========深克隆===============");
        PrototypeShallow prototypeShallow = new PrototypeShallow();
        prototypeShallow.setName("felix");
        prototypeShallow.setDate(new Date());
        PrototypeShallow cloneLight = (PrototypeShallow) prototypeShallow.clone();
        
        System.out.println("对象 : " + (prototypeShallow == cloneLight));
        System.out.println("对象.ֵname: " + (prototypeShallow.getName() == cloneLight.getName()));
        System.out.println("对象.Date: " + (prototypeShallow.getDate() == cloneLight.getDate()));
        System.out.println("对象.Date.time: " + (prototypeShallow.getDate().getTime() == cloneLight.getDate().getTime()));
    }
}
